//
//  HZTabBarController.swift
//  555wobo
//
//  Created by 黄某某 on 15/12/15.
//  Copyright © 2015年 黄某某. All rights reserved.
//

import UIKit

class HZTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let mainTabar=HZTabBar()
        setValue(mainTabar, forKeyPath: "tabBar")
        
//        self.tabBar.tintColor=UIColor.orangeColor()
        
        let homeVC = HZHomeController()
        addChildViewController(homeVC, title: "首页", imageName: "tabbar_home")
        
        let messageVC=HZMessageController()
        addChildViewController(messageVC, title: "消息", imageName: "tabbar_message_center")
        
        let discoverVC=HZDiscoverController()
        addChildViewController(discoverVC, title: "发现", imageName: "tabbar_discover")
        
        let profileVC=HZProfileController()
        addChildViewController(profileVC, title: "我", imageName: "tabbar_profile")
        

    }
    
    private func addChildViewController(controller:UIViewController,title:String,imageName:String){
        
        controller.title=title
        controller.tabBarItem.image=UIImage(named: imageName)
        let highlightedImageName = imageName + "_highlighted"
        controller.tabBarItem.selectedImage = UIImage(named: highlightedImageName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        addChildViewController(UINavigationController.init(rootViewController: controller))
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.redColor()], forState: UIControlState.Selected)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
